package org.example.clavier;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import static java.lang.Thread.sleep;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-06-02
 * Time:21:24
 * Text：
 */
public class Test1 {
    public static void main(String[] args) throws InterruptedException {
        ChromeOptions options = new ChromeOptions();
        options.setBinary("D:\\Chrome\\chrome.exe");
        options.addArguments("---remote-allow-origins=*");
        WebDriver driver = new ChromeDriver(options);
        driver.get("https://www.baidu.com");

        WebElement element = driver.findElement(By.xpath("//*[@id=\"kw\"]"));
        element.sendKeys("我爱Java");
        driver.findElement(By.cssSelector("#kw")).sendKeys(Keys.CONTROL,"A");//全选
        sleep(3000);
        driver.findElement(By.cssSelector("#kw")).sendKeys(Keys.CONTROL,"c");
        sleep(3000);
        driver.findElement(By.cssSelector("#kw")).sendKeys(Keys.CONTROL,"x");
        sleep(3000);
        driver.findElement(By.cssSelector("#kw")).sendKeys(Keys.CONTROL,"v");

    }
}
